package cmd

import (
	"github.com/spf13/cobra"
)

var (
	shopID string // 门店id
)

func init() {
	rootCmd.AddCommand(reviewCmd)
	reviewCmd.Flags().StringVarP(&shopID, "shop", "S", "", "门店ID")
}

var reviewCmd = &cobra.Command{
	Use:              string(Review),
	Short:            "Read informations of shop review",
	Long:             `Read informations of shop review`,
	TraverseChildren: true,
	Run: func(cmd *cobra.Command, args []string) {
		slog.Debugf("shopID => %s", shopID)
		// if len(args) == 0 {
		// 	slog.Error("need search keyword. use: dp search 咬不得")
		// 	return
		// }
		// keyword := args[0]

		NewRunner().
			LoadCredentialFromFile().
			ValidateShop(shopID).
			FetchReviewsSince(shopID, 30).
			CleanReviewInfo(
				DataCleanFunc(RemoveEmtpy),
				DataCleanFunc(RemoveCollapseReviewButtonText),
			).
			DumpReviewInfo().
			ReviewReset().
			Run()
	},
}
